package cn.linjianhui.flink.sample.model;

import org.apache.commons.compress.utils.Sets;

import java.math.BigDecimal;
import java.util.Set;

public class HourlyAccumulator {
    private int orderHour;
    private BigDecimal orderAmount;
    private Set<String> orderIds;

    public HourlyAccumulator() {
        orderAmount = BigDecimal.ZERO;
        orderIds = Sets.newHashSet();
    }

    public int getOrderHour() {
        return orderHour;
    }

    public void setOrderHour(int orderHour) {
        this.orderHour = orderHour;
    }

    public BigDecimal getOrderAmount() {
        return orderAmount;
    }

    public void setOrderAmount(BigDecimal orderAmount) {
        this.orderAmount = orderAmount;
    }

    public Set<String> getOrderIds() {
        return orderIds;
    }

    public void setOrderIds(Set<String> orderIds) {
        this.orderIds = orderIds;
    }

    public void addOrderAmount(BigDecimal orderAmount) {
        this.orderAmount = this.orderAmount.add(orderAmount);
    }

    public boolean addOrderId(String orderId) {
        return orderIds.add(orderId);
    }

    public boolean containsOrder(String orderId) {
        return this.orderIds.contains(orderId);
    }
}
